(function($, window) {
	var v3Restuser = window.v3Restuser = {};
	var baseRequest = window.baseRequest;
	var appConfig = window.appConfig;
	var commonTool = window.commonTool;
	var dataManager = window.dataManager;
	var baseUrl = appConfig.v3ServiceUrl + '/ace/oasis/oasis-rest-user/restapp';
	
	//Add by dongyi
    //验证注册手机号是否存在
    var isPhoneNumExistUrl = baseUrl + '/users/isExistPhone/';
    v3Restuser.isPhoneNumExist = function(phoneNum,callback){
    	baseRequest.commonGet(isPhoneNumExistUrl+phoneNum, 5000, function (code, data) {
    		console.log("code:"+code);
    		console.log(data);
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (code === 0) {
                if (data.errcode) {
                    callback(1);
                } else {
                    callback(0, data.data);
                }
            }
        });
    }
    
    //验证注册邮箱是否存在
    var isEmailUserExistUrl = baseUrl + '/o2oportal/sso/isExistedUser';
    v3Restuser.isEmailExist = function(userEmail,callback){
    	 baseRequest.commonPost(isEmailUserExistUrl, JSON.stringify({user_email:userEmail}), 5000, function (code, data) {
    	 	console.log(JSON.stringify(data));
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.ret_code === 0) {
                callback(0);
            } else {
                callback(1, data.ret_code);
            }
        });
    }
    
    var userRegistUrl = baseUrl + '/o2oportal/sso/registUser';
    v3Restuser.phoneUserRegist = function (phoneUserInfo, callback) {
        baseRequest.commonPost(userRegistUrl, JSON.stringify(phoneUserInfo), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.error_code === 0) {
                callback(0);
            } else {
                callback(1, data);
            }
        });
    }
    v3Restuser.emailUserRegist = function (emailUserInfo, callback) {
        baseRequest.commonPost(userRegistUrl, JSON.stringify(emailUserInfo), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.error_code === 0) {
                callback(0);
            } else {
                callback(1, data);
            }
        });
    }
    
    //手机找回密码
    var resetPasswordUrl = baseUrl + '/o2oportal/resetPwd';
    v3Restuser.resetPwd = function (resetInfo, callback) {
        baseRequest.commonPost(resetPasswordUrl,JSON.stringify(resetInfo), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.error_code === 0) {
                callback(0);
            } else {
                callback(1, data.error_message);
            }
        });
    }
    
    //邮箱找回密码
    var resetPwdByEmailUrl = baseUrl + '/o2oportal/sso/resetPwdWithEmail';
    v3Restuser.resetPwdByEmail = function (emailReset, callback) {
        baseRequest.commonPost(resetPwdByEmailUrl,JSON.stringify(emailReset), 5000, function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.error_code === 0) {
                callback(0);
            } else {
                callback(1, data.error_message);
            }
        });
    }
	// end
	
	/* lkf6877 start */
	v3Restuser.getUserColumn = function(userName,callback){
		baseRequest.commonGet(baseUrl + '/usercolumn',10000,function(code,data){
			if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data.code === 0) {
                callback(0, data.data);
            } else {
                callback(1, data.message);
            }
		})
	}
	/* lkf6877 end */
})(mui, window);